package com.zy.qudadid.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.GuDingLuCheng;
import com.zy.qudadid.presenter.IndexAllPresenter;
import com.zy.qudadid.ui.adapter.base.BaseAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by ninos on 2016/9/20.
 */
public class IndexAllAdapter extends BaseAdapter<IndexAllAdapter.VHolder, GuDingLuCheng, IndexAllPresenter> {

    public IndexAllAdapter(Context context, IndexAllPresenter indexAllPresenter, View header) {
        super(context, indexAllPresenter, header);
        isAddFooter = false;
    }

    public IndexAllAdapter(Context context, IndexAllPresenter indexAllPresenter) {
        super(context, indexAllPresenter);
        isAddFooter = false;
    }

    @Override
    public int provideItemLayoutId() {
        return R.layout.activity_index_all_item;
    }

    @Override
    public VHolder createVH(ViewGroup parent, int viewType, View view) {
        return new VHolder(view);
    }

    @Override
    public void bindData(VHolder holder, int position) {
        GuDingLuCheng passenger = data.get(position);

//        Glide.with(context)
//                .load(passenger.dr_av)
//                .fitCenter()
//                .crossFade()
//                .transform(new GlideCircleTransform(context))
//                .placeholder(R.drawable.adm)
//                .into(holder.ini_img);
//
//        holder.ini_name.setText(StringUtil.isEmpty(passenger.dr_name)?"未命名":passenger.dr_name);
//        holder.ini_phone.setText("电话："+passenger.mobile);

//        holder.ini_time.setText(passenger.s);
        if(!TextUtils.isEmpty(passenger.start_place)) {
            holder.ini_startadds.setText(passenger.start_place);
            holder.ini_endadds.setText(passenger.end_place);
        }else{
            holder.ini_startadds.setText(passenger.start_area);
            holder.ini_endadds.setText(passenger.end_area);
        }
    }

    class VHolder extends RecyclerView.ViewHolder {

        @Nullable
        @Bind(R.id.ini_img)ImageView ini_img;
        @Nullable @Bind(R.id.ini_name)TextView ini_name;
        @Nullable @Bind(R.id.ini_phone)TextView ini_phone;
        @Nullable @Bind(R.id.ini_time)TextView ini_time;
        @Nullable @Bind(R.id.ini_startadds)TextView ini_startadds;
        @Nullable @Bind(R.id.ini_endadds)TextView ini_endadds;

        VHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}